#ifndef __LOGIN_DEVICE_H__
#define __LOGIN_DEVICE_H__

#include "list.h"

#define USER_ID_SIZE        (10 + 1)
#define USER_PASSWD_SIZE    (10 + 1)
#define ADMIN_ID_SIZE       (2)
#define ADMIN_PASSWD_SIZE   (2)
#define NAME_SIZE           (20)
#define CITIZEN_ID_SIZE     (18 + 1)
#define PHONE_NUM_SIZE      (11 + 1)

struct user {
    char user_id[USER_ID_SIZE];
    char passwd[USER_PASSWD_SIZE];
    char name[NAME_SIZE];
    char citizen_id[CITIZEN_ID_SIZE];
    char phone_num[PHONE_NUM_SIZE];
    struct list_head list;
};

struct admin {
    char admin_id[ADMIN_ID_SIZE];
    char passwd[ADMIN_PASSWD_SIZE];
};

extern void admin_init(struct admin *admin);
extern int user_init(struct list_head *user_head);
extern int is_user_info_repeat(char *user_id_or_phone_num, char *citizen_id,
                        char *phone_num, struct list_head *user_head);
extern int match_user_info(char *user_id_or_phone_num, char *passwd,
                            struct list_head *user_head);
extern int user_destroy(struct list_head *user_head);
extern void admin_destroy(struct admin *admin);
extern int build_all_user_buffer(char *user_buffer, struct list_head *user_head);
extern int write_user_file_onetime(struct list_head *user_head);

#endif